package org.farm.config;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
public class IotConfig {

    @Value("${aliyun.iot.accessKey}")
    private String accessKey;

    @Value("${aliyun.iot.accessSecret}")
    private String accessSecret;

    @Value("${aliyun.iot.consumerGroupId}")
    private String consumerGroupId;

    @Value("${aliyun.iot.iotInstanceId}")
    private String iotInstanceId;

    @Value("${aliyun.iot.clientId}")
    private String clientId;

    @Value("${aliyun.iot.host}")
    private String host;

    @Value("${aliyun.region.id}")
    private String region;

    @Value("${aliyun.iot.endpoint}")
    private String endpoint;

//    @Value("${aliyun.iot.productKey}")
//    private String productKey;

    public DefaultAcsClient initClient() {
        DefaultProfile profile = DefaultProfile.getProfile(region, accessKey, accessSecret);
        return new DefaultAcsClient(profile);
    }

}
